package com.sskj.hhrt.mine;

import com.sskj.base.data.User;
import com.sskj.hhrt.BasePresenter;
import com.sskj.base.utils.RxUtils;
import com.sskj.hhrt.api.Api;
import com.sskj.hhrt.api.ApiObserver;
import com.sskj.hhrt.api.SimpleHttpObserver;
import com.sskj.hhrt.api.SystemInfo;
import com.sskj.hhrt.mine.data.BankBean;
import com.sskj.hhrt.mine.data.PayWayBean;
import com.sskj.hhrt.mine.data.RechargeBean;

import java.util.List;


/**
 * @author Hey
 * Create at  2019/03/27
 */
class RechargePresenter extends BasePresenter<RechargeActivity> {

    // 入金获取字段
    public void getPayWay(String money) {
        Api.getInstance().getPayWay(money)
                .compose(RxUtils.transform())
                .subscribe(new ApiObserver<RechargeBean>(this, true) {
                    @Override
                    public void onSuccess(RechargeBean data) {
                        xinghuoPay(money, data.getOrdnum());
                    }

                    @Override
                    public void onComplete() {
                        super.onComplete();
                        mView.stopRefresh();
                    }
                });
    }

    public void getBank(String account) {
//        Api.getInstance().getBank("getCardList", account)
//                .compose(RxUtils.transform())
//                .subscribe(new ApiObserver<List<BankBean>>(this, true) {
//                    @Override
//                    public void onSuccess(List<BankBean> data) {
//                        mView.setBankData(data);
//                    }
//
//                    @Override
//                    public void onComplete() {
//                        super.onComplete();
//                        mView.stopRefresh();
//                    }
//                });
    }


    public void getSystemInfo() {
//        Api.getInstance().getSystemInfo("sysSet")
//                .compose(RxUtils.transform())
//                .subscribe(new ApiObserver<SystemInfo>(this, true) {
//                    @Override
//                    public void onSuccess(SystemInfo data) {
//                        mView.setSysInfo(data);
//                    }
//
//                    @Override
//                    public void onComplete() {
//                        super.onComplete();
//                        mView.stopRefresh();
//                    }
//                });
    }


    public void xinghuoPay(String amount, String outTradeNo) {
        Api.getInstance().xinghuoPay(amount, outTradeNo, "1")
                .compose(RxUtils.transform())
                .subscribe(new ApiObserver<String>(this, true) {
                    @Override
                    public void onSuccess(String data) {
                        mView.onPaySuccess(data);
                    }
                });
    }

    public void getAccountDetail(String account, boolean showLoading) {
        Api.getInstance().accountDetail()
                .compose(RxUtils.transform())
                .subscribe(new ApiObserver<User>(this, showLoading) {
                    @Override
                    public void onSuccess(User data) {
                        mView.setAccountInfo(data);
                    }
                });
    }


}
